<template>
  <div @click="handleClick">
    Child-1 - {{subTitle}}
  </div>
</template>

<script>
import eventBus from '@/plugin/eventBus'

export default {
  name: 'Child1',
  props: {
    subTitle: {
      type: String,
      default: "subTitle"
    }
  },

  mounted() {
    // 调用父组件事件/或数据对象
    this.$parent.handleClick()
    console.log(this.$attrs)
  },

  methods: {
    handleClick() {
      eventBus.$emit('handleClick', 'eventBus通讯')
      this.$root.$emit('handleClick1', '$root通讯')
      this.$eventBus.emit('handleClick', 'Vue.use方式使用eventBus')
    }
  }
}
</script>
